//
//  AY_BookOpinionCell2.m
//  AiYue
//
//  Created by boWen on 2023/11/13.
//

#import "AY_BookOpinionCell2.h"

@interface AY_BookOpinionCell2 ()
@property (nonatomic,strong) UIView * bg_View;//底部圆角
@property (nonatomic,strong) UILabel * shenqingLabel;
@property (nonatomic,strong) UILabel * wenContentLabel;
@end

@implementation AY_BookOpinionCell2


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addAllSubviewsWithUI];
    }
    return self;
}


- (void)addAllSubviewsWithUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = COLOR_Bg;
    
    self.bg_View = [AYTool createViewWithFrame:CGRectZero andBg:[UIColor whiteColor] andRadius:YNUM(6) andAddSubView:self.contentView];
    [self.bg_View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.contentView);
    }];

    self.shenqingLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"申请说明" andTextColor:COLOR(@"#909090") andBgColor:nil andFont:[UIFont boldSystemFontOfSize:YNUM(12)] andLines:1 andRadius:0 andAddSubView:self.bg_View];
    [self.shenqingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bg_View).offset(YNUM(16));
        make.left.equalTo(self.bg_View).offset(YNUM(12));
        make.right.equalTo(self.bg_View).offset(YNUM(-12));
        make.height.mas_offset(YNUM(20));
    }];
    
    self.wenContentLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#909090") andBgColor:nil andFont:YFont(12) andLines:4 andRadius:0 andAddSubView:self.bg_View];
    [self.wenContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.shenqingLabel.mas_bottom).offset(YNUM(8));
        make.left.equalTo(self.bg_View).offset(YNUM(12));
        make.right.equalTo(self.bg_View).offset(YNUM(-12));
        make.bottom.equalTo(self.bg_View).offset(YNUM(-2));
    }];
    
}

- (void)setModel:(ConfigModel *)model {
    if (!kStringIsEmpty(model.qiushu_desc)) {
        self.wenContentLabel.text = [model.qiushu_desc stringByReplacingOccurrencesOfString:@"##" withString:@"\n"];
        NSString *labelText = self.wenContentLabel.text;
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
        NSMutableParagraphStyle *styles = [NSMutableParagraphStyle new];
        styles.lineSpacing  = 8;
        [attributedString addAttribute:NSParagraphStyleAttributeName value:styles range:NSMakeRange(0, [labelText length])];
        self.wenContentLabel.attributedText = attributedString;
    }
}
@end
